package com.gl.rent;

import cn.hutool.core.util.StrUtil;
import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.HotCity;
import com.haixiaoke.saas.repository.service.IHotCityService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 热门城市Controller
 *
 * @author zhiping
 * @date 2023-04-06
 */
@RestController
@RequestMapping("/hot/city")
public class HotCityController extends BaseController {

    @Autowired
    private  IHotCityService hotCityService;

    /**
     * 查询热门城市列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HotCity hotCity) {
        startPage();
        List<HotCity> list = hotCityService.selectHotCityList(hotCity);
        return getDataTable(list);
    }

    /**
     * 获取热门城市详细信息
     */
    @GetMapping(value = "/{cityId}")
    public AjaxResult getInfo(@PathVariable("cityId") Long cityId) {
        return success(hotCityService.selectHotCityByCityId(cityId));
    }

    /**
     * 新增热门城市
     */
    @PostMapping
    public AjaxResult add(@RequestBody HotCity hotCity) {
        return toAjax(hotCityService.insertHotCity(hotCity));
    }

    /**
     * 修改热门城市
     */
    @PutMapping
    public AjaxResult edit(@RequestBody HotCity hotCity) {
        return toAjax(hotCityService.updateHotCity(hotCity));
    }

    /**
     * 删除热门城市
     */
    @DeleteMapping("/{cityIds}")
    public AjaxResult remove(@PathVariable Long[] cityIds) {
        return toAjax(hotCityService.deleteHotCityByCityIds(cityIds));
    }
}
